<?php
/***********************************************
	This class would retrieve data from a PHP
	array.
************************************************/
class ThumbnailFilePathSetter {
	private $extension = NULL;
	private $domainTrimmed = NULL;
	private $counter = NULL;
	private $thumbnailFilePath = NULL;
	
	/************************************************************/
	
	function setThumbnailFilePath($domain, $folderPath, $imageLink) {
		if ((strpos($imageLink, ".jpg") != FALSE)
				|| (strpos($imageLink, ".jpeg") != FALSE)) {
			$this->extension = '.jpg';
		} elseif ((strpos($imageLink, ".png") != FALSE)) {
			$this->extension = '.png';
		} elseif ((strpos($imageLink, ".gif") != FALSE)) {
			$this->extension = '.gif';
		}
		
		$this->domainTrimmed = explode(".", $domain, 2);
		$this->counter = 1;
		$this->thumbnailFilePath = $folderPath.$this->domainTrimmed[0]
									."_".$this->counter
									.$this->extension;
		
		while (file_exists($this->thumbnailFilePath)) {
			$this->counter++;
			$this->thumbnailFilePath = $folderPath.$this->domainTrimmed[0]
										."_".$this->counter
										.$this->extension;
		}
		return $this->thumbnailFilePath;
	}
}
?>